
if exists(select name from sysobjects where name = 'sp_TinCreateEdit')
	drop proc sp_TinCreateEdit
go
/*
	Created by: Phuoc NH
	Created on: 04/012/2013 (dd/mm/yyyy)
	Description: 
	--

	File:$sql-scripts/Proc.sp_TinCreateEdit.sql
*/

create proc sp_TinCreateEdit
@TinId int,
@TieuDe nvarchar(1000),
@NoiDung nvarchar(max),
@LoaiTinId int,
@NguoiTao int,
@ThuTu int
as
begin
	if(@TinId=0)
		begin
			insert into Tin(TieuDe, NoiDung, LoaiTinId, ThuTu, NguoiTao, NgayTao, TrangThai) values(@TieuDe, @NoiDung, @LoaiTinId, @ThuTu, @NguoiTao, GETDATE(), 1)
		end
	else
		begin	
			update Tin set TieuDe=@TieuDe, NoiDung=@NoiDung, LoaiTinId=@LoaiTinId, ThuTu=@ThuTu, NguoiSua=@NguoiTao, NgaySua=GETDATE() where TinId=@TinId
		end
end

